//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;

namespace OpenLS.UI
{
    partial class GroupBoxResources
    {
        public GroupBoxResources()
        {
            InitializeComponent();
        }
        void OnToggleClick(object sender, RoutedEventArgs args)
        {
            ToggleButton b = (ToggleButton)sender;
            GroupBox groupBox = (GroupBox)b.TemplatedParent;
            Popup popup = (Popup)groupBox.Template.FindName("popup", groupBox);
            if (b.IsChecked.GetValueOrDefault() && !popup.IsOpen)
                popup.IsOpen = true;
        }
        void OnPopupClosed(object sender, EventArgs args)
        {
            Popup popup = (Popup)sender;
            GroupBox groupBox = (GroupBox)popup.TemplatedParent;
            ToggleButton b = (ToggleButton)groupBox.Template.FindName("toggle", groupBox);
            if (Mouse.DirectlyOver != b)
                b.IsChecked = false;
        }
    }
}